package com.zs.rocketmqstream.functional;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author madison
 * @description
 * @date 2021/7/4 15:53
 */
@Configuration
public class FunConfig {

    @Bean
    public Supplier<String> myFuncOutput() {
        System.out.println("函数式编程 发送消息");
        AtomicInteger i = new AtomicInteger(1);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
        return () -> formatter.format(LocalDateTime.now()) + " 函数式编程 Hello from Supplier " + (i.getAndIncrement());
    }

    @Bean
    public Consumer<String> myFuncInput() {
        System.out.println("函数式编程 接收消息");
        return System.out::println;
    }
}
